package com.example.service.impl;

import com.example.mapper.EmpLogMapper;
import com.example.pojo.EmpLog;

import com.example.service.EmpLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service
public class EmpLogServiceImpl implements EmpLogService {

    @Autowired
    private EmpLogMapper empLogMapper;
    //    事务的传播行为
    @Transactional(propagation = Propagation.REQUIRES_NEW)//Propagation.REQUIRES_NEW 新事务
//      Propagation.REQUIRED    默认加入当前事务，没有就创建 但是这里需要另外一个事务
    //加个事务，为了避免  添加用户 失败在 finally 用同一个事务导致回滚，记录不了

    @Override
    public void insertLog(EmpLog empLog) {
        empLogMapper.insert(empLog);
    }
}
